package com.ywjh.inter.common;

import java.io.IOException;
import java.io.InputStream;
import java.util.Properties;

import com.ywjh.inter.utils.StrUtil;

public class SystemConfig {

	static {
		init();
	}
	/**
	 * 数据库IP
	 */
	public static String DATABASE_URL;
	/**
	 * 数据库名
	 */
	public static String DATABASE_NAME;
	/**
	 * 数据库用户名
	 */
	public static String DATABASE_USERNAME;
	/**
	 * 数据库密码
	 */
	public static String DATABASE_PASSWORD;

	public static String SERVER_DOMAIN;

	public static String CDN_SERVER;
	public static String MEMCACHED_IP;
	public static int MEMCACHED_PORT;
	public static String ORI;
	public static String APP_NAME;
	public static String HX_URL;
	public static String CLIENT_SECERT;
	public static String CLIENT_ID;
	public static String RTC_appId;
	public static String RTC_appCertificate;

	public static String DOMAIN;

	public static String SOCKET;
	public static String SOCKET_PORT;

	public static void init() {
		Properties prop = new Properties();
		InputStream in = null;
		try {
			in = SystemConfig.class.getResourceAsStream("/config.properties");
			prop.load(in);
			DATABASE_URL = prop.getProperty("DATABASE_URL");
			DATABASE_NAME = prop.getProperty("DATABASE_NAME");
			DATABASE_USERNAME = prop.getProperty("DATABASE_USERNAME");
			DATABASE_PASSWORD = prop.getProperty("DATABASE_PASSWORD");
			SERVER_DOMAIN = prop.getProperty("SERVER_DOMAIN");
			CDN_SERVER = prop.getProperty("CDN_SERVER");
			MEMCACHED_IP = prop.getProperty("MEMCACHED_IP");
			MEMCACHED_PORT = StrUtil.getInt(prop.getProperty("MEMCACHED_PORT"), 11211);
			ORI=prop.getProperty("ORI");
			APP_NAME=prop.getProperty("APP_NAME");
			HX_URL=prop.getProperty("HX_URL");
			CLIENT_SECERT=prop.getProperty("CLIENT_SECERT");
			CLIENT_ID=prop.getProperty("CLIENT_ID");
			RTC_appId=prop.getProperty("RTC_appId");
			RTC_appCertificate=prop.getProperty("RTC_appCertificate");
			DOMAIN=prop.getProperty("DOMAIN");
			SOCKET=prop.getProperty("SOCKET");
			SOCKET_PORT=prop.getProperty("SOCKET_PORT");
		} catch (IOException e) {
			e.printStackTrace();
		} finally {
			try {
				in.close();
			} catch (IOException e) {
				e.printStackTrace();
			}
		}
	}

}
